# Vue3 项目设置脚本
Write-Host "正在设置 Vue3 RTSP 播放器项目..." -ForegroundColor Green

# 复制 jsmpeg.min.js
$sourceFile = "..\src\main\resources\static\jsmpeg.min.js"
$targetFile = ".\public\jsmpeg.min.js"

if (Test-Path $sourceFile) {
    Copy-Item -Path $sourceFile -Destination $targetFile -Force
    Write-Host "✓ 已复制 jsmpeg.min.js" -ForegroundColor Green
} else {
    Write-Host "✗ 未找到源文件: $sourceFile" -ForegroundColor Red
    Write-Host "  请确保在正确的目录下运行此脚本" -ForegroundColor Yellow
    exit 1
}

# 检查 Node.js
$nodeVersion = node --version 2>$null
if ($LASTEXITCODE -eq 0) {
    Write-Host "✓ Node.js 版本: $nodeVersion" -ForegroundColor Green
} else {
    Write-Host "✗ 未安装 Node.js" -ForegroundColor Red
    Write-Host "  请访问 https://nodejs.org/ 下载安装" -ForegroundColor Yellow
    exit 1
}

# 安装依赖
Write-Host "`n正在安装依赖..." -ForegroundColor Cyan
npm install

if ($LASTEXITCODE -eq 0) {
    Write-Host "`n✓ 设置完成！" -ForegroundColor Green
    Write-Host "`n运行以下命令启动开发服务器:" -ForegroundColor Cyan
    Write-Host "  npm run dev" -ForegroundColor Yellow
} else {
    Write-Host "`n✗ 依赖安装失败" -ForegroundColor Red
    exit 1
}

